package com.songtai.service.impl;

import java.io.Serializable;

import com.songtai.dao.ApplyDao;
import com.songtai.po.Apply;
import com.songtai.service.ApplyService;
import com.songtai.util.PageBean;

/**
 * 应聘信息
 * 
 * @author lx
 * 
 */
public class ApplyServiceImpl implements ApplyService {

	private ApplyDao applyDao;

	@Override
	public void delApply(String ids) {
		String temp = ids.substring(0, ids.length() - 1);
		if(temp.length() == 1) {
			String hql = "delete from Apply where id =(" + temp + ")";
			applyDao.deleteEntities(hql);
		}else {
		String[] temp2 = temp.split(",");
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < temp2.length; i++) {
			sb.append("'" + temp2[i] + "',");
		}
		temp = sb.toString();
		temp = temp.substring(0, temp.length() - 1);
		String hql = "delete from Apply where id in(" + temp + ")";
		applyDao.deleteEntities(hql);
		}
	}

	@Override
	public PageBean getApplies(PageBean pageBean) {
		return applyDao.findPageEntities(pageBean);
		//return applyDao.findPageEntitiesBySql(pageBean);
	}

	@Override
	public Apply getApply(Serializable id) {
		return applyDao.readObjectById(id);
	}
	
	/**
	 * 保存应聘信息
	 * 
	 * @param apply
	 */
	@Override
	public void saveApply(Apply apply) {
		applyDao.createObject(apply);
	}

	public void setApplyDao(ApplyDao applyDao) {
		this.applyDao = applyDao;
	}

}
